local guicai = fk.CreateSkill {
  name = "emo__guicai",
}

Fk:loadTranslationTable{
  ["emo__guicai"] = "鬼才",
  [":emo__guicai"] = "当一名角色的判定牌生效前，你可以用一张牌代替之。",
  ["#emo__guicai-ask"] = "是否发动“鬼才”，用一张牌修改 %dest 的[%arg]判定？",
}

guicai:addEffect(fk.AskForRetrial, {
  guicai = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(guicai.name) and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToCards(player, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = guicai.name,
      pattern = ".",
      prompt = "#emo__guicai-ask::"..target.id .. ":" .. data.reason ,
      cancelable = true,
    })
    if #cards > 0 then
      event:setCostData(self, {cards = cards})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:changeJudge{
      card = Fk:getCardById(event:getCostData(self).cards[1]),
      player = player,
      data = data,
      skillName = guicai.name,
    }
  end,
})

return guicai
